package com.panopset.sf.menu;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import javax.swing.JCheckBoxMenuItem;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

import com.panopset.compat.Strings;
import com.panopset.nls.MsgProps;
import com.panopset.sf.FontManager;
import com.panopset.sf.MessageMenuBar;
import com.panopset.sf.MnemonicGroup;
import com.panopset.sf.Windoc;
import com.panopset.sf.FontManager.Size;

/**
 * Swing menu.
 * 
 * @author Karl Dinwiddie
 * 
 */
public class SwingMenuBar {

	protected final Windoc sd;

	/**
	 * 
	 * @param doc
	 *            SwingDoc associated with this menu.
	 */
	public SwingMenuBar(final Windoc doc) {
		sd = doc;
	}

	/**
	 * SwingDoc menu bar.
	 */
	private JMenuBar menuBar;

	private FileMenu fileMenu;
	private FontMenu fontMenu;
	private HelpMenu helpMenu;
	
	private FileMenu getFileMenu() {
		if (fileMenu == null) {
			fileMenu = new FileMenu(sd);
		}
		return fileMenu;
	}

	/**
	 * @return Font menu.
	 */
	public FontMenu getFontMenu() {
		if (fontMenu == null) {
			fontMenu = new FontMenu(sd);
		}
		return fontMenu;
	}
	
	private HelpMenu getHelpMenu() {
		if (helpMenu == null) {
			helpMenu = new HelpMenu(sd);
		}
		return helpMenu;
	}

	/**
	 * 
	 * @return SwingDoc menu bar.
	 */
	public JMenuBar getMenuBar() {
		if (menuBar == null) {
			menuBar = getMessageMenuBar().getMenuBar();
			menuBar.add(getFileMenu().getMenu());
			menuBar.add(getFontMenu().getMenu());
			menuBar.add(getHelpMenu().getMenu());
		}
		return menuBar;
	}

	private MessageMenuBar mmb;
	
	public MessageMenuBar getMessageMenuBar() {
		if (mmb == null) {
			mmb = new MessageMenuBar();
		}
		return mmb;
	}
	
	/**
	 * Menu bar mnemonic group.
	 */
	private final MnemonicGroup barMG = new MnemonicGroup();
	
	public MnemonicGroup getMenuBarMnemonicGroup() {
		return barMG;
	}
}
